﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Shop.Model.Custom;
using Shop.Model;

namespace Shop.Framework.Control {
    public class LoginControl:ViewUserControl {

        public bool IsLoggedIn { 
            get {
                return WebCart.Self.CurrentCustomer.IdCustomer != 0;
            }
        }

        public Customer CurrentCustomer {
            get {
                return WebCart.Self.CurrentCustomer;
            }
        }

        public string ErrorMessage {
            get;
            private set;
        }

        public bool HasError {
            get {
                return ErrorMessage != null;
            }
        }

        protected override void OnLoad(EventArgs e) {
            if (ViewData["LoginError"] != null)
                ErrorMessage = ViewData["LoginError"].ToString();
            base.OnLoad(e);
        }


    }
}
